java program to count the occurrences of each character